﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class WebControl_InsertGroupAccount : System.Web.UI.UserControl
{
    private string groupname = null;
    ListAndProcessData wsv = new ListAndProcessData();
    protected void Page_Load(object sender, EventArgs e)
    {              
             
    }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        var groupaccount = wsv.loadGroupName();
        foreach (var item in groupaccount)
        {
            groupname = item.Groupname;
            if (groupname.Equals(txtgroupname.Text))
            {
                Response.Redirect("Loi.aspx");
                break;
            }                       
        }
        bool check = wsv.insertGroupAccount(txtgroupname.Text, txtdescription.Text);
        if (check)
        {
            Response.Redirect("ShowGroupAccount.aspx");
            
        }
        else
        {
            Response.Redirect("Loi.aspx");
        }
    }
}